package com.fc.tms.dao;

import java.util.Date;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.fc.framework.dao.HibernateBaseDAO;
import com.fc.tms.constant.Team;
import com.fc.tms.entity.JobTransferLog;

@Repository("jobTransferLogDAO")
public class JobTransferLogDAO extends HibernateBaseDAO<JobTransferLog, Long> {

    public void clear() {
        this.createQuery("DELETE FROM JobTransferLog").executeUpdate();
    }

    public JobTransferLog get(Long studentId, Team team, Date transferDate) {
        String hql = "FROM JobTransferLog o WHERE o.studentId = :studentId AND o.team = :team AND o.transferDate = :transferDate";
        Query query = this.createQuery(hql);
        query.setParameter("studentId", studentId);
        query.setParameter("team", team);
        query.setParameter("transferDate", transferDate);
        query.setMaxResults(1);
        return (JobTransferLog) query.uniqueResult();
    }
}
